Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Collections.Generic
Imports facebook.web
Imports System.Web.Configuration
Imports facebook
Imports facebook.Schema

Namespace FBMLSample.config
	Partial Public Class Setup
		Inherits CanvasFBMLBasePage
		Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)
			Me.RequireLogin = False
		End Sub
		Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
			Dim t1 = WebConfigurationManager.AppSettings("TemplateID1")
            Dim t2 = WebConfigurationManager.AppSettings("TemplateID2")
            Dim dict = New Dictionary(Of String, String)
            dict.Add("application_name", "Smiley.NET")
            dict.Add("callback_url", callback)
            dict.Add("tab_default_name", "Smile.NET")
            dict.Add("profile_tab_url", "mysmiles.aspx")
            dict.Add("publish_action", "Smile at!")
            dict.Add("publish_url", callback & "handlers/otherPublishHandler.aspx")
            dict.Add("publish_self_action", "Smile!")
            dict.Add("publish_self_url", callback & "handlers/publishHandler.aspx")
            dict.Add("info_changed_url", callback & "handlers/infoHandler.aspx")
            dict.Add("wide_mode", "1")

			Me.API.admin.setAppProperties(dict)
            Dim one_line_story = New List(Of String)
            one_line_story.Add("{*actor*} is feeling {*mood*} today")
            Dim short_story = New List(Of feedTemplate)()
            Dim short_story_template = New feedTemplate
            With short_story_template
                .TemplateTitle = "{*actor*} is feeling so {*mood*} today"
                .TemplateBody = "{*actor*} just wanted to let you know that he is so {*mood*} today"
                .PreferredLayout = "1"
            End With
            short_story.Add(short_story_template)

            Dim full_story = New feedTemplate
            With full_story
                .TemplateTitle = "{*actor*} is feeling very {*mood*} today"
                .TemplateBody = "<div style=""padding: 10px;width : 200px;height : 200px;margin: auto;text-align: center;border: black 1px;cursor: pointer;border: black solid 2px;background: orange;color: black;text-decoration: none;""><div style=""font-size: 60pt;font-weight: bold;padding: 40px;"">{*emote*}</div><div style=""font-size: 20px; font-weight:bold;"">{*mood*}</div></div>"
            End With
            If String.IsNullOrEmpty(t1) Then
                Dim bundle1id As Long = Me.API.feed.registerTemplateBundle(one_line_story, short_story, full_story)
                Me.template1.Text = "Bundle 1 is " & bundle1id
            Else
                Me.template1.Text = "Bundle 1 is " & t1

            End If

            one_line_story = New List(Of String)
            one_line_story.Add("{*actor*} just wanted to {*emote*} at {*target*} today")
            short_story = New List(Of feedTemplate)()
            short_story_template = New feedTemplate
            With short_story_template
                .TemplateTitle = "{*actor*} just wanted to {*emote*} at {*target*} today"
                .TemplateBody = "Always a great day to {*emoteaction*}"
                .PreferredLayout = "1"

            End With
            short_story.Add(short_story_template)

            full_story = New feedTemplate
            With full_story
                .TemplateTitle = "{*actor*} just wanted to {*emote*} at {*target*} today"
                .TemplateBody = "Always a great day to {*emoteaction*}"
            End With

            If String.IsNullOrEmpty(t2) Then
                Dim bundle2id As Long = Me.API.feed.registerTemplateBundle(one_line_story, short_story, full_story)
                Me.template2.Text = "Bundle 2 is " & bundle2id
            Else
                Me.template2.Text = "Bundle 2 is " & t2

            End If

            Dim options = New List(Of info_item)()
            options.Add(New info_item With {.label = "Happy", .image = callback & "images/smile0.jpg", .sublabel = "", .description = "The original and still undefeated.", .link = "http://apps.facebook.com/" & suffix & "/smile.aspx?smile=1"})
            options.Add(New info_item With {.label = "Indifferent", .image = callback & "images/smile1.jpg", .sublabel = "", .description = "meh....", .link = "http://apps.facebook.com/" & suffix & "/smile.aspx?smile=2"})
            options.Add(New info_item With {.label = "Sad", .image = callback & "images/smile2.jpg", .sublabel = "", .description = "Oh my god! you killed my dog!", .link = "http://apps.facebook.com/" & suffix & "/smile.aspx?smile=3"})
            options.Add(New info_item With {.label = "Cool", .image = callback & "images/smile3.jpg", .sublabel = "", .description = "Yeah. whatever", .link = "http://apps.facebook.com/" & suffix & "/smile.aspx?smile=4"})
            Me.API.profile.setInfoOptions("My Smiles", options)

        End Sub
	End Class
End Namespace
